if(SOLAR_WITH_QT)
    include(ForceIncludeHeader)

    find_package(PNG REQUIRED)
    file(GLOB_RECURSE ui_srcs *.cpp)
    file(GLOB_RECURSE ui_srcs_cuda *.cu)
    add_library(solar_ui STATIC ${ui_srcs})
    add_library(solar_ui_cuda STATIC ${ui_srcs_cuda})
    target_include_directories(solar_ui PUBLIC "${CMAKE_SOURCE_DIR}/source")
    target_include_directories(solar_ui_cuda PUBLIC "${CMAKE_SOURCE_DIR}/source")
    target_include_directories(solar_ui PUBLIC ${Boost_INCLUDE_DIRS})
    target_link_directories(solar_ui PUBLIC ${Boost_LIBRARY_DIR})

    if(HAVE_STD_FORMAT)
        target_compile_definitions(solar_ui PUBLIC "HAVE_STD_FORMAT")
        target_compile_options(solar_ui PUBLIC "${STD_FORMAT_EXTRA_FLAGS}")
        if (CUDA20_SUPPORTED)
            target_compile_definitions(solar_ui_cuda PUBLIC "HAVE_STD_FORMAT")
            target_compile_options(solar_ui_cuda PUBLIC "${STD_FORMAT_EXTRA_FLAGS}")
        endif()
    else()
        find_package(fmt REQUIRED)
        target_link_libraries(solar_ui PUBLIC fmt::fmt)
    endif()

    if(HAVE_STD_PRINT)
        target_compile_definitions(solar_ui PUBLIC "HAVE_STD_PRINT")
        target_compile_options(solar_ui PUBLIC "${STD_FORMAT_EXTRA_FLAGS}")
        if (CUDA23_SUPPORTED)
            target_compile_definitions(solar_ui_cuda PUBLIC "HAVE_STD_PRINT")
            target_compile_options(solar_ui_cuda PUBLIC "${STD_FORMAT_EXTRA_FLAGS}")
        endif()
    endif()
    target_link_libraries(solar_ui
        PRIVATE Qt6::Quick
        PRIVATE Qt6::DataVisualization
        PRIVATE Qt6::Gui
    )

    find_package(TBB REQUIRED)

    try_compile(
        HAVE_ONEAPI_TBB
        "${CMAKE_SOURCE_DIR}/cmake"
        "${CMAKE_SOURCE_DIR}/cmake/try_compile_oneapi_tbb.cpp"
        COMPILE_DEFINITIONS "${TRY_COMPILE_STD_CXX_FLAGS}"
        OUTPUT_VARIABLE TRY_COMPILE_OUTPUT
        LINK_LIBRARIES TBB::tbb
    )

    if(NOT HAVE_ONEAPI_TBB)
        message(FATAL_ERROR "OneAPI TBB is not found")
    endif()

    target_compile_definitions(solar_ui PRIVATE "SOLAR_USE_QT")
    target_compile_definitions(solar_ui PRIVATE "GLM_FORCE_INTRINSICS")
    target_compile_options(solar_ui
        PRIVATE $<$<CXX_COMPILER_ID:AppleClang,IBMClang,Clang>:-Xclang=-fconstexpr-steps=1145141919>)
    target_compile_options(solar_ui
        PRIVATE $<$<CXX_COMPILER_ID:GNU>:-fconstexpr-ops-limit=1145141919>)
    target_link_libraries(solar_ui PUBLIC VectorClass2)
    target_link_libraries(solar_ui PUBLIC PNG::PNG)
    target_link_libraries(solar_ui PUBLIC glm::glm)
    target_link_libraries(solar_ui PRIVATE TBB::tbb)
    target_link_libraries(solar_ui PRIVATE TBB::tbbmalloc)
    target_link_libraries(solar_ui PRIVATE gcem)
    target_link_libraries(solar_ui_cuda PUBLIC PNG::PNG)
    target_link_libraries(solar_ui PUBLIC glad)
    target_link_libraries(solar_ui PRIVATE CUDA::cudart) 
    target_link_libraries(solar_ui_cuda PUBLIC glad)
    target_link_libraries(solar_ui_cuda PRIVATE gcem)
    set_property(TARGET solar_ui_cuda PROPERTY CUDA_SEPARABLE_COMPILATION OFF)
    target_compile_definitions(solar_ui_cuda PRIVATE "SOLAR_CUDA_STANDALONE_COMPILE")
    force_include_header(solar_ui_cuda CUDA "${CMAKE_SOURCE_DIR}/source/utils/cuda/CudaWrappers.h")
    if(CMAKE_SYSTEM_NAME MATCHES "Windows")
        if(${CMAKE_CUDA_COMPILER_ID} MATCHES "Clang")
            target_compile_definitions(solar_ui_cuda PRIVATE alloca=__builtin_alloca)
        else()
            target_compile_definitions(solar_ui_cuda PRIVATE alloca=_alloca)
        endif()
    endif()
    if(MSVC)
        if(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
            target_compile_definitions(solar_ui PRIVATE alloca=__builtin_alloca)
        else()
            target_compile_definitions(solar_ui PRIVATE alloca=_alloca)
    endif()
endif()
endif()
